package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Insert("INSERT INTO article(content,created,user_id) " +
            "VALUES(#{content},#{created},#{userId})")
    int insertArticle(Article article);
    
    @Delete("DELETE FROM article WHERE id=#{id}")
    int deleteArticleById(Integer id);
    
    @Update("UPDATE article " +
            "SET content=#{content},created=#{created},user_id=#{userId} " +
            "WHERE id=#{id}")
    int updateArticleById(Article article);
    
    @Select("SELECT id,content,created,user_id userId " +
            "FROM article " +
            "WHERE id=#{id}")
    Article selectArticleById(Integer id);
    
    @Select("SELECT id,content,created,user_id userId " +
            "FROM article")
    List<Article> selectArticles();
}
